

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

//查询界面
public class Query extends JPanel implements ActionListener {
    private Icon backImage = Util.getIcon("/image/pane.jpg");//返回按钮图
    private ATM frame;//顶级容器实例
    private JButton backBtn;//返回按钮
    private JLabel jLabelBack;//返回文本
    private JLabel balanceJLabel;//余额提示插件
    private JLabel balancesJLabel;//余额值
    public Query(ATM frame) {
        this.frame = frame;
        //设置空布局
        this.setLayout(null);
        this.setOpaque(false);
        //余额提示插件
        balanceJLabel = new JLabel("余额为：");
        balanceJLabel.setBounds(230, 220, 400, 50);
        balanceJLabel.setFont(new Font("宋体", Font.PLAIN, 25));
        this.add(balanceJLabel);
        //余额值
        balancesJLabel = new JLabel();
        balancesJLabel.setBounds(420, 220, 300, 50);
        balancesJLabel.setFont(new Font("宋体", Font.BOLD, 35));
        this.add(balancesJLabel);
        //返回按钮
        //返回按钮
        jLabelBack = new JLabel("返  回");
        jLabelBack.setBounds(900, 300, 100, 50);
        jLabelBack.setForeground(Color.white);
        this.add(jLabelBack);
        jLabelBack.setFont(new Font("宋体", Font.BOLD, 25));
        backBtn = new JButton(backImage);
        backBtn.setBounds(870, 300, 140, 50);
        backBtn.setOpaque(false);
        this.add(backBtn);
        backBtn.addActionListener(this);//建立联系
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == backBtn) {
            frame.switchPanel("menu");
        }
    }

    public void steJLabelBalances(double balances) {
        balancesJLabel.setText(balances + "");
    }

}
